﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminMaster.master" AutoEventWireup="true"
    EnableEventValidation="false" Inherits="ObjectManagement" CodeBehind="ObjectManagement.aspx.cs" %>

<asp:Content ID="Content3" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        $(function () {
            HideAddNew();
        });
        function ShowAddNew() {
            $("#divAddNew").show();
            return false;
        }
        function HideAddNew() {
            $("#divAddNew").hide();
            return false;
        }        
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="Div1">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td class="GroupHeader" style="height: 18px; text-align: left;" colspan="4" valign="top">
                    Object List
                </td>
            </tr>
            <tr style="height: 30px">
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:UpdatePanel ID="updPnlObjectList" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:GridView ID="gvObjectList" Width="100%" runat="server" AutoGenerateColumns="False"
                                EnableModelValidation="True" DataKeyNames="ObjectID" OnRowDeleting="gvObjectList_RowDeleting"
                                OnRowCommand="gvObjectList_RowCommand">
                                <Columns>
                                    <asp:BoundField DataField="Name" HeaderText="Name" />
                                    <asp:BoundField DataField="Description" HeaderText="Description" />
                                    <asp:BoundField DataField="Href" HeaderText="Href" />
                                    <asp:BoundField DataField="ParentName" HeaderText="Parent" />
                                    <asp:BoundField DataField="Sort" HeaderText="Sort" />
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:LinkButton ID="edit" runat="server" CausesValidation="false" CommandName="EditObject">Edit</asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:CommandField ShowDeleteButton="True" />
                                </Columns>
                            </asp:GridView>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="click" />
                        </Triggers>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <asp:Button ID="btnAddNew" runat="server" Text="Add New" OnClientClick="ShowAddNew()"
                        OnClick="btnAdd_Click" CausesValidation="false" />
                </td>
            </tr>
        </table>
    </div>
    <asp:UpdatePanel ID="updPnlAddNewObject" runat="server" UpdateMode="Conditional"
        ChildrenAsTriggers="true">
        <ContentTemplate>
            <div id="divAddNew">
                <fieldset>
                    <table width="100%" cellspacing="0" cellpadding="0">
                        <tr align="left">
                            <td colspan="3">
                                <asp:ValidationSummary ID="valSummaryAddNew" runat="server" ValidationObject="vgAddNew" />
                                <asp:Label ID="lblErrorAddNew" runat="server" CssClass="error"></asp:Label>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Name
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rqdValName" runat="server" SetFocusOnError="true"
                                    ValidationObject="vgAddNew" ErrorMessage="The name field is required" ControlToValidate="txtName"
                                    Display="None"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Description
                            </td>
                            <td width="35%">
                                <asp:TextBox ID="txtDescription" TextMode="MultiLine" Rows="10" Columns="25" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                <fieldset>
                                    <legend>Assign Role </legend>
                                    <table width="100%">
                                        <tr>
                                            <td width="25%">
                                                <asp:ListBox ID="lstRoles" runat="server" SelectionMode="Multiple" Width="223px">
                                                </asp:ListBox>
                                            </td>
                                            <td>
                                                <asp:Button ID="btnAddRoles" Text=">" runat="server" CausesValidation="false" OnClick="btnAddRoles_Click" />
                                                <br />
                                                <asp:Button ID="btnRemoveRoles" Text="<" runat="server" CausesValidation="false"
                                                    OnClick="btnRemoveRoles_Click" />
                                            </td>
                                            <td>
                                                <asp:ListBox ID="lstAssignedRoles" runat="server" SelectionMode="Multiple" Width="223px">
                                                </asp:ListBox>
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Href
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtHref" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Parent
                            </td>
                            <td colspan="2">
                                <asp:DropDownList ID="ddlParentMenu" runat="server">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Type
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtType" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Target
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtTarget" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Sort Order
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtSortOrder" runat="server"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="regExpValSortOrder" runat="server" ControlToValidate="txtSortOrder"
                                    ValidationObject="vgAddNew" ErrorMessage="The sort order is invalid" ValidationExpression="^\d+$"
                                    Display="None" SetFocusOnError="True"></asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr style="height: 30px">
                            <td colspan="3" align="center">
                                <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" ValidationObject="vgAddNew" />
                                <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false"
                                    OnClientClick="javascript: return HideAddNew()" />
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAddNew" EventName="click" />
            <asp:AsyncPostBackTrigger ControlID="gvObjectList" EventName="rowcommand" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
